import env from './static/config/env'
export default {
  /*
  ** Nuxt rendering mode
  ** See https://nuxtjs.org/api/configuration-mode
  */
  mode: 'universal',

  server: {
    port: 3336
  },

  /*
  ** Nuxt target
  ** See https://nuxtjs.org/api/configuration-target
  */
  target: 'server',
  /*
  ** Headers of the page
  ** See https://nuxtjs.org/api/configuration-head
  */
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ],
    // 设置语言
    htmlAttrs: {
      lang: 'zh-cn'
    }
  },

  /*
  ** Global CSS
  */
  css: [
    '@/assets/css/rest.css',
    'ant-design-vue/dist/antd.css',
    '@/assets/iconfont/iconfont.css',
    '@/assets/sass/quick-ref.scss',
    'swiper/css/swiper.css'
  ],

  router: {
    middleware: ['headers'] // 全局使用中间件
  },

  /*
  ** Plugins to load before mounting the App
  ** https://nuxtjs.org/guide/plugins
  */
  plugins: [
    // { src: '@/plugins/antd-ui', ssr: true },
    { src: '@/plugins/element-ui.js', ssr: true },
    { src: '@/plugins/vant-ui.js', ssr: true },
    { src: '@/plugins/lazy-load.js', ssr: false },
    { src: '@/plugins/axios', ssr: true },
    { src: '@/plugins/vue-awesome-swiper.js', ssr: false },
    { src: '@/plugins/vuex-storage.js', ssr: false },
    { src: '@/plugins/marquee', ssr: false },
    { src: '@/plugins/scroll', ssr: false },
    { src: '@/plugins/videoPlayer', mode: 'client' }
  ],
  /*
  ** Auto import components
  ** See https://nuxtjs.org/api/configuration-components
  */
  components: true,
  /*
  ** Nuxt.js dev-modules
  */
  /*   buildModules: [
    // Doc: https://github.com/nuxt-community/eslint-module
    '@nuxtjs/eslint-module'
  ], */
  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/proxy',
    '@nuxtjs/pwa',
    '@nuxtjs/style-resources',
    'cookie-universal-nuxt'
  ],

  /*
  ** Axios module configuration
  ** See https://axios.nuxtjs.org/options
  */
  axios: {
    proxy: true
  },

  proxy: {
    '/api': {
      // target: env.dev.ENV_API, //可以直接更改环境参数，包括线上也生效
      target: env[process.env.MODE].ENV_API, // 更具不同环境参数打包
      pathRewrite: {
        '^/api': ''
      }
    }
  },

  /* 引入自定义scss */
  styleResources: {
    scss: ['@/assets/sass/variables.scss', '@/assets/sass/mixins.scss']
  },

  /*
  ** Build configuration
  ** See https://nuxtjs.org/api/configuration-build/
  */
  build: {
    extractCSS: { allChunks: true }, // 部署时css样式提取到一个css文件中
    babel: {
      plugins: [
        [
          'component',
          {
            libraryName: 'element-ui',
            styleLibraryName: 'theme-chalk'
          }
        ]
      ]
    }
  }
}
